// index.js文件
Component({
  data: {
    active: 0,
    list: [
        
        {
            "url":"/pages/market/market",
            "text":"市场",
            "icon":"chart-trending-o",
            "info":0
        },
        {
            "url": "/pages/index/index",
            "text": "选股",
            "icon": 'home-o',
            "info": 0
          },
        {
        "url": "/pages/strategy/strategy",
        "text": "策略",
        "icon": 'cart-o',
        "info": 0
      },
    
      {
        "url": "/pages/ucenter/index",
        "text": "我的",
        "icon": 'user-o',
        "info": 0
      }
    ]
  },
  methods: {
    onChange(e) {
      wx.switchTab({
        url: this.data.list[e.detail].url
      });
      this.setData({
        active: e.detail
      });
    },


    init() {
      const page = getCurrentPages().pop();
      this.setData({
        active: this.data.list.findIndex(item => item.url === `/${page.route}`)
      });
    },

    setCartNumber(cartNumber) {
      let listTemp = this.data.list
      listTemp[2].info = cartNumber
      this.setData({
        list: listTemp
      })
    }
  }
});